/*    */ package com.zimbra.cs.service.mail;
/*    */ 
/*    */ import com.zimbra.common.mailbox.Color;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.soap.MailConstants;
/*    */ import com.zimbra.cs.mailbox.Mailbox;
/*    */ import com.zimbra.cs.mailbox.OperationContext;
/*    */ import com.zimbra.cs.mailbox.Tag;
/*    */ import com.zimbra.cs.service.util.ItemIdFormatter;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class CreateTag
/*    */   extends MailDocumentHandler
/*    */ {
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException
/*    */   {
/* 42 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 43 */     Mailbox mbox = getRequestedMailbox(zsc);
/* 44 */     OperationContext octxt = getOperationContext(zsc, context);
/* 45 */     ItemIdFormatter ifmt = new ItemIdFormatter(zsc);
/*    */     
/* 47 */     Element t = request.getElement("tag");
/* 48 */     String name = t.getAttribute("name");
/* 49 */     String rgb = t.getAttribute("rgb", null);
/*    */     Tag tag;
/*    */     Tag tag;
/* 52 */     if (rgb != null) {
/* 53 */       Color color = new Color(rgb);
/* 54 */       tag = mbox.createTag(octxt, name, color);
/*    */     }
/*    */     else {
/* 57 */       byte color = (byte)(int)t.getAttributeLong("color", 0L);
/* 58 */       tag = mbox.createTag(octxt, name, color);
/*    */     }
/*    */     
/* 61 */     Element response = zsc.createElement(MailConstants.CREATE_TAG_RESPONSE);
/* 62 */     if (tag != null)
/* 63 */       ToXML.encodeTag(response, ifmt, octxt, tag);
/* 64 */     return response;
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/mail/CreateTag.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */